<template>
  <el-dialog
    v-model="dialogVisible"
    title="删除确认"
    width="420"
  >
    <span>确定要删除车型吗</span>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button
          type="primary"
          @click="okDel"
        >
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import { ref, defineExpose, defineEmits } from 'vue'
import { ElMessage } from 'element-plus'
import { deleteRowDataApi } from '../../../api/VehicleManagement'
const dialogVisible = ref(false)
const getId = ref('')

const emit = defineEmits(['clickDialog'])
//确定删除
const okDel = async () => {
  dialogVisible.value = true
  await deleteRowDataApi(getId.value)
  await emit('clickDialog')
  dialogVisible.value = false
  ElMessage({
    message: '删除成功',
    type: 'success',
    plain: true,
  })
}

//打开弹窗
defineExpose({
  showDialog(onOff: boolean, id: string) {
    getId.value = id
    dialogVisible.value = onOff
  },
})
</script>
<style lang="less">
</style>